package com.action;

import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import com.dto.Fenqi;
import com.service.FenqiService;

@RestController
public class FenqiAction {
	@Autowired
	private FenqiService fq;
	private List<Fenqi> queryFenqi;
	
	//查询分期
//	@RequestMapping("/queryFenqi.do")
//	public ModelAndView queryFenqi(Fenqi fenqi,HttpSession sess) {
//		ModelAndView mv= new ModelAndView();
//		List<Fenqi> fenqiType = fq.queryFenqi(fenqi);
//		for (Fenqi fenqi2 : fenqiType) {
//			System.out.println("#############"+fenqi2.getTid()+fenqi2.getTname());
//			System.out.println("~~~~~~~~~~"+fenqi2.getFid()+fenqi2.getFname());
//		}
//			if(fenqiType!=null) {
//				sess.setAttribute("fenqiType", fenqiType);
//				mv.setViewName("/c");
//			}
//			//itcast-springboot/src/main/webapp/c.jsp
//		return mv;
//	}
	
	@RequestMapping("/queryFenqi.do")
	public Map<String, Object> queryFenqi(Fenqi fenqi,HttpSession sess){
		Map<String, Object> json = new HashMap<String, Object>();
		List<Fenqi> queryFenqi = fq.queryFenqi(fenqi);
		for (int i = 0; i < queryFenqi.size(); i++) {
			System.out.println(queryFenqi.get(i));
		}
		 if(queryFenqi!=null && queryFenqi.size()>0) {
			 json.put("queryFenqi", queryFenqi);
		 }
		return json;
		
	}
}
